Example 5: Atomic Reference
This example demonstrates how to specify an attachment to another record. The import data specifies a record in the Loans module that attaches to a Parties record (the borrower).
This example also specifies a table (Business Telephone Number) in the Parties module.
The fields loaded are:
Fields |
Back-end name |
---|---|
Loan Direction | InfDirection
|
Loan Purpose | InfLoanPurpose
|
Commencement Date | DatLoanCommencementDate
|
Due Date | DatLoanDueDate
|
Borrower/Lender | InfBorrowerLenderRef
|
The attachment field in the Loans module is Borrower/Lender: (Loan Details):
If we check the Field Level information for this field, the following displays:
The back-end name is InfBorrowerLender, but when specifying an attachment field we use its Link name: InfBorrowerLenderRef.
For display purposes only, the import data below is presented with column headings listed vertically rather than horizontally. The first row of any tab or comma delimited file must include the column names. The appropriate layout is:
InfDirection
|
InfLoanPurpose
|
DatLoanCommencementDate
|
Outgoing | The loan is for research purposes. | 15-Jan-06 |
Incoming | The loan is for an upcoming exhibition. | 10-Mar-06 |
Outgoing | A loan without a borrower or due date! | 17-Mar-66 |
The import data is:
Column Name (must appear as the first row of the import data file) |
Record 1 |
Record 2 |
Record 3 |
---|---|---|---|
InfDirection
|
Outgoing | Incoming | Outgoing |
InfLoanPurpose
|
The loan is for research purposes. | The loan is for an upcoming exhibition. | A loan without a borrower or due date! |
DatLoanCommencementDate
|
15-Jan-06 | 10-Mar-06 | 17-Mar-66 |
DatLoanDueDate
|
15-Jan-07 | 10-Jul-06 |
|
InfBorrowerLenderRef.NamPartyType
|
Person | Organization |
|
InfBorrowerLenderRef.NamFirst
|
John
|
|
|
InfBorrowerLenderRef.NamLast
|
Smith
|
|
|
InfBorrowerLenderRef.NamOrgaisation
|
|
The Art Gallery of Salsam |
|
InfBorrowerLenderRef.NamBusiness_tab(1)
|
|
61393470011
|
|
The attachment reference is constructed by combining the Link name for the attachment field with a back-end field name from the attached module.
For example, to specify that the Borrower/Lender field in the Loans module should attach to a record for John Smith in the Parties module, you might specify:
InfBorrowerLenderRef.NamFirst
InfBorrowerLenderRef.NamLast
And to specify a row in a table in the attachment module, simply designate the row number (as we've already seen when specifying a table in the same module). For example, the first row in Business: (Telephone Numbers) is specified as:
InfBorrowerLenderRef.NamBusiness_tab(1)
When the import is processed a search for a record for John Smith is initiated in the Parties module; if a record is found it can be used for the attachment. If no record is found, one can be created in the Parties module using the values specified in the data file, and then the two records will be linked together.
The XML for this example is:
<?xml version="1.0" encoding="UTF-8"?>
<table>
<!--First record-->
<tuple>
<!--First the atom fields in the Loans module are specified-->
<atom name="InfDirection">Outgoing</atom>
<atom name="InfLoanPurpose">The loan is for research purposes.</atom>
<atom name="DatLoanCommencementDate">15 January 2006</atom>
<atom name="DatLoanDueDate">15 January 2007</atom>
<!--Next the attachment field in the Loans module is specified, followed by each atom field in the Parties module-->
<tuple name="InfBorrowerLenderRef">
<atom name="NamPartyType">Person</atom>
<atom name="NamFirst">John</atom>
<atom name="NamLast">Smith</atom>
</tuple>
</tuple>
<!--Second record-->
<tuple>
<atom name="InfDirection">Incoming</atom>
<atom name="InfLoanPurpose">The loan is for an upcoming exhibition.</atom>
<atom name="DatLoanCommencementDate">10 March 2006</atom>
<atom name="DatLoanDueDate">10 July 2006</atom>
<tuple name="InfBorrowerLenderRef">
<atom name="NamPartyType">Organization</atom>
<atom name="NamOrganisation">The Art Gallery of Salsam</atom>
<!--As well as specifying atomic fields in the attachment module, tables can also be specified. In this example, the first row in the Business: (Telephone Numbers) table is referenced-->
<table name="NamBusiness_tab">
<tuple>
<atom>+61 3 9347 0011</atom>
</tuple>
</table>
</tuple>
</tuple>
<!--Third record-->
<tuple>
<atom name="InfDirection">Outgoing</atom>
<atom name="InfLoanPurpose">A loan without a borrower or due date!</atom>
<atom name="DatLoanCommencementDate">17 March 1966</atom>
</tuple>
</table>
When this data is imported into EMu using the Typical import options, the following occurs:
- The Parties module is searched using the details in the specified Parties fields (e.g. NamFirst). If no matching record is found, a record is created in the Parties module and attached to the Loans module using the InfBorrowerLender field. If there is a match, the new Loans record (created next) is attached to the matching Parties record.
- A record in the Loans module is created using the values in the Loans fields.